import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:ladder_cash/generated/assets.dart';
import 'package:ladder_cash/value/app_colors.dart';

class MyAppBar extends AppBar {
  List<Widget>? actions;

  MyAppBar(_title,
      {super.key,
      this.actions,
      backgroundColor,
      backClick,
      isBack = true,
      bgImg  })
      : super(
          leading: isBack
              ? InkWell(
                  onTap: backClick ?? () => Get.back(),
                  child: Stack(
                    children: [
                      Center(
                        child: LImage.easy(Assets.molopNewBackwhite, 20.w, 20.w),
                      )
                    ],
                  ),
                )
              : null,
          elevation: 0,
          centerTitle: true,

          // 标题居中
          backgroundColor: Colors.white,
          flexibleSpace: bgImg == null
              ? null
              : Container(
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage(bgImg),
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
          title: (_title is Widget)
              ? _title
              : Text(_title,
                  style: TextStyle(
                      fontSize: 15.sp,
                      fontWeight: FontWeight.bold,
                      color: AppColors.textColor)),
          actions: actions ?? [],
        );
}
